package ru.lukyanets.transmission.protocol.model.torrent;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.Arrays;

/**
 * @author Sergey Lukyanets
 */
public enum Priority {
    LOW(-1),
    NORMAL(0),
    HIGH(1);

    private final int value;

    Priority(int value) {
        this.value = value;
    }

    @JsonValue
    int getValue() {
        return value;
    }

    @JsonCreator
    public static Priority of(int value) {
        return Arrays.stream(values()).filter(v -> v.value == value).findFirst().orElse(null);
    }
}
